package com.kmproject.haifu.mvp.ui.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kmproject.haifu.R;
import com.kmproject.haifu.mvp.model.entity.beans.MemberCenterUserInfoBean;
import com.kmproject.haifu.mvp.model.entity.beans.MyStoryBean;
import com.kmproject.haifu.mvp.presenter.MyStorySelectNewPresenter;

import java.util.ArrayList;
import java.util.List;

public class MyStoryXZDPAdapter extends BaseQuickAdapter<MyStoryBean, BaseViewHolder> {
    private MemberCenterUserInfoBean mmemberCenterUserInfoBean;
    private int mselectMode=0;
    private MyStorySelectNewPresenter mmyStorySelectNewPresenter;
    public MyStoryXZDPAdapter(MemberCenterUserInfoBean memberCenterUserInfoBean,@Nullable List<MyStoryBean> data,int selectMode,MyStorySelectNewPresenter myStorySelectNewPresenter) {
        super(R.layout.mystore_selectstory_item,data);
        mmemberCenterUserInfoBean=memberCenterUserInfoBean;
        mselectMode=selectMode;
        this.mmyStorySelectNewPresenter=myStorySelectNewPresenter;
    }

    @Override
    protected void convert(BaseViewHolder helper, MyStoryBean item) {
     helper.<RecyclerView>getView(R.id.mystore_selectstory_item_RecyclerView).setLayoutManager(new LinearLayoutManager(mContext));
     helper.<TextView>getView(R.id.mystore_selectstory_item_title_txt).setText(item.getStoreType()+"（"+item.getTotal()+"）");
     helper.<RecyclerView>getView(R.id.mystore_selectstory_item_RecyclerView).setAdapter(new MyStoryXZDPItemAdapter(item.getStoreType(),mmemberCenterUserInfoBean,item.getResult(),mselectMode==0?false:true,mmyStorySelectNewPresenter));
    if (helper.getPosition()==getData().size()-1)
    {
        helper.getView(R.id.mystore_selectstory_item_view1).setVisibility(View.VISIBLE);
     }else {
        helper.getView(R.id.mystore_selectstory_item_view1).setVisibility(View.GONE);
    }
    }



    public void setMselectMode(int mselectMode) {
        this.mselectMode = mselectMode;
        notifyDataSetChanged();
    }
}
